<link href="<?=base_url('assets/css/fileuploader.css')?>" rel="stylesheet" type="text/css">
<script src="<?=base_url('assets/js/fileuploader.js')?>"></script>
<div class="col-md-12">		
	<div class="panel panel-primary">
		<div class="panel-heading">
		  <h3 class="panel-title">Thông tin tài khoản</b></h3>
		  </div>
		<div class="panel-body">
			<?php if($user['loai'] == 1): //ca nhan pg-pb-model?>	
			<div id="tabs">
				<?php if (isset($message)):?>
				<?php echo '<div class="alert alert-info"><a class="close" data-dismiss="alert">×</a><strong>'.$message.'</strong></div>';?>
				<?php endif;?>
				<?php if (isset($danger)):?>
				<?php echo '<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a><strong>'.$danger.'</strong></div>';?>
				<?php endif;?>
				<?php if(isset($error)):?>
				<?php echo '<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a><strong>'.$error.'</strong></div>';?>
				<?php endif;?>
				<ul class="nav nav-tabs">					
					<li class="active"><a href="#ho_so" data-toggle="tab">Hồ sơ PG</a></li>
					<li><a href="#dichvu" data-toggle="tab">Dịch vụ & Catse</a></li>
					<li><a href="#album" data-toggle="tab">Album ảnh</a></li>
					<li><a href="#tai_khoan" data-toggle="tab">Tài khoản</a></li>
				</ul>			
				<div class="tab-content">
					<div id="ho_so" class="tab-pane active pad-top10" style="overflow:hidden;">
					<?php $hoso = isset($hoso) ? $hoso : array();
						$this->load->view('account/form_info', $hoso)?>
					</div>
					<div id="dichvu" class="tab-pane fade pad-top10">				
						<div style="width:43%" class="left">
							<p class="text-center avatar-title">Dịch vụ chưa đăng ký</p>
							<ul class="list-group" id="dichvu_cdk">
							<?php foreach($dichvu_cdk as $obj):?>
								<li id="item_<?=$obj->id?>" class="list-group-item">
									<div class="checkbox">
										<label>
											<input type="checkbox" class="" value="<?=$obj->id?>"><?=$obj->ten?>
										</label>
									</div>
								</li>
							<?php endforeach;?>
							</ul>
						</div>	
						<form id="frmdichvu" method="post" action="<?=site_url('tai-khoan').'#dichvu'?>">				
							<div class="left text-center" style="width:14%;margin-top: 150px;">
								<input class="btn btn-default" type="button" value="Đăng ký >>" onclick="dang_ky_dvu()"/>
								<p>&nbsp;</p>
								<input class="btn btn-default" type="button" value="&nbsp;&nbsp;&nbsp;<< Hủy&nbsp;&nbsp;&nbsp;&nbsp;" onclick="huy_dang_ky_dvu()"/>
								<p>&nbsp;</p>
								<input name="type" type="hidden" value="dichvu"/>
								<input name="dichvu_json" type="hidden" value="" id="dichvu_json"/>
								<input class="btn btn-primary" type="submit" value="Cập nhật" onclick="get_dvu_dky(event);"/>
							</div>				
							<div class="left" style="width:43%;">
								<p class="text-center avatar-title">Dịch vụ đã đăng ký</p>
								<div class="form-group">
									<table class="table table-bordered" id="dichvu_dk">
										<thead>		
											<tr>
												<th>Dịch vụ</th>
												<th style="width:35%">Catse</th>
											</tr>
										</thead>
										<tbody>
										<?php foreach($dichvu_dk as $obj):?>
											<tr id="dvu_dk_<?=$obj->id?>">
												<td>
													<div class="checkbox ">
														<label>
															<input type="checkbox" class="dichvu_dk" value="<?=$obj->id?>"><?=$obj->ten?>
														</label>
													</div>
												</td>
												<td>
													<input type="text" id="catse<?=$obj->id?>" class="catse form-control text-right" value="<?=number_format($obj->catse,0,'','')?>">
												</td>
											</tr>
										<?php endforeach;?>
									</table>
								</div>	
							</div>
						</form>
					</div>			
					<div id="album" class="tab-pane fade pad-top10">
						<div id="file-uploader">		
						</div>
						<div class="qq-upload-extra-drop-area hide">Drop files here too</div>
						<script type="text/javascript">        
							function createUploader(){            
								var ajaxuploader = new qq.FileUploader({
									element: document.getElementById('file-uploader'),
									action: "<?php echo base_url('upload/upload_files/album');?>",
									allowedExtensions: ['jpg', 'jpeg', 'png', 'gif', 'bmp'],
									uploadButtonText:	'Tải ảnh lên',
									cancelButtonText: 'Hủy tải ảnh',
									failUploadtext:	'Tải ảnh không thành công',
									dragText:			'Kéo thả ảnh vào đây để tải lên',
									debug: false,
									extraDropzones: [qq.getByClass(document, 'qq-upload-extra-drop-area')[0]],
									template:   '<div class="qq-uploader">' +
										'<div class="qq-upload-drop-area"><span>{dragText}</span></div>' +
										'<div class="qq-upload-btn btn btn-default left">{uploadButtonText}</div>' +
										'<ul class="qq-upload-list left hide"></ul>' +
										'</div>',
									fileTemplate: '<li class="left">' +
										'<span class="qq-progress-bar"></span>' +
										'<span class="qq-upload-spinner"></span>' +
										'<span class="qq-upload-finished"></span>' +
										'<span class="qq-upload-file"></span>' +
										'<span class="qq-upload-size"></span>' +
										'<a class="qq-upload-cancel btn btn-danger" href="#">{cancelButtonText}</a>' +
										'<span class="qq-upload-failed-text alert alert-danger">{failUploadtext}</span>' +
										'</li>',
									classes: {
										// used to get elements from templates
										button: 'qq-upload-btn',
										drop: 'qq-upload-drop-area',
										dropActive: 'qq-upload-drop-area-active',
										dropDisabled: 'qq-upload-drop-area-disabled',
										list: 'qq-upload-list',
										progressBar: 'qq-progress-bar',
										file: 'qq-upload-file',
										spinner: 'qq-upload-spinner',
										finished: 'qq-upload-finished',
										size: 'qq-upload-size',
										cancel: 'qq-upload-cancel',
										// added to list item <li> when upload completes
										// used in css to hide progress spinner
										success: 'qq-upload-success',
										fail: 'qq-upload-fail',
										successIcon: null,
										failIcon: null,
									},
									showMessage: function(message){
										alert(message);
									},
									onProgress: function(id, fileName, loaded, total) {
										var progress = Math.round((loaded/total)*100);
										$('.progress .bar').css({
											'width':  progress,
										});
									},
									onError: function(id, fileName, xhr){
										console.log(xhr);
									},
									onComplete: function(id, fileName, responseJSON){
										var img = responseJSON;
										var li = '<li>';
										li += '<img class="img-thumbnail" src="/assets/timthumb.php?w=160&h=170&src=/uploads/images/full/'+img.filename+'"/>';
										li += '<div class="album-desc text-center">';
										li += '<span class="">Thứ tự: </span>';
										li += '<input type="text" class="form-control text-right" maxlength="2" name="thumb['+img.albumId+']" value="0" style="width:70px"/>';
										li += '</div>';
										li += '</li>';
										jQuery('.uploaded-list').append(li);
									},
								});   
							}
							window.onload = createUploader;							
						</script>
						<p class="clear">&nbsp;</p>
						<form role="form" class="form-horizontal" action="<?=site_url('tai-khoan').'#album'?>" method="post">
						<ul class="uploaded-list">
						<?php foreach($album as $obj):
						?>
							<li class="clear">
								<a rel="fancybox" href="/uploads/images/full/<?=$obj->thumb?>">
									<img class="img-thumbnail" src="/assets/timthumb.php?w=160&h=170&src=/uploads/images/full/<?=$obj->thumb?>">
								</a>
								<div class="album-desc text-center">
									<span class="">Thứ tự: </span>
									<input type="text" style="width:50px" class="form-control text-right" maxlength="2" name="thumb[<?=$obj->id?>]" value="<?=$obj->thu_tu?>">
									<span><a href="#" onclick="xoa_anh(event,this)">Xóa</a>
								</div>
							</li>
						<?php
							endforeach;
						?>
						</ul>
						<div class="col-md-12 text-center">
						<?php if($album):?>
							<input name="type" type="hidden" value="album"/>
							<input class="btn btn-primary" type="submit" value="Cập nhật"/>
						<?php endif;?>
						</div>
						</form>
						<script type="text/javascript">
							jQuery(function(){
								jQuery('a[rel=fancybox]').fancybox({
									'transitionIn'	:	'elastic',
									'transitionOut'	:	'elastic',
									'speedIn'		:	600, 
									'speedOut'		:	200, 
									'autoPlay'		:	true,
									'overlayShow'	:	true
								});
							});
						</script>
					</div>			
					<div id="tai_khoan" class="tab-pane fade">
						<div class="col-md-12">
							<label class="control-label">Số điểm: <b><?=$point ? $point->so_tien : '0' ?></b></label>
						</div>				
						<div class="col-md-6">
							<h3>Lịch sử thanh toán</h3>
						</div>
					</div>
				</div>				
			</div>
		<?php elseif($user['loai'] == 2): //nha tuyen dung?>
			<div id="tabs">
				<?php if (isset($message)):?>
				<?php echo '<div class="alert alert-info"><a class="close" data-dismiss="alert">×</a><strong>'.$message.'</strong></div>';?>
				<?php endif;?>
				<?php if (isset($danger)):?>
				<?php echo '<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a><strong>'.$danger.'</strong></div>';?>
				<?php endif;?>
				<?php if(isset($error)):?>
				<?php echo '<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a><strong>'.$error.'</strong></div>';?>
				<?php endif;?>
				<ul class="nav nav-tabs">					
					<li class="active"><a href="#ho_so" data-toggle="tab">Hồ sơ</a></li>
					<li><a href="#tai_khoan" data-toggle="tab">Tài khoản</a></li>
				</ul>			
				<div class="tab-content">						
					<div id="ho_so" class="tab-pane active ">					
					<?php $hoso = isset($hoso) ? $hoso : array();
						$this->load->view('account/form_info', $hoso)?>
						<div class="col-md-6">
							<form role="form" method="post" action="<?=site_url('tai-khoan')?>">
								<div class="col-md-7">
									<div class="form-group">
										<label class="control-label">Email: <b><?=$user['email']?></b></label>
										<input type="password" class="form-control" id="password" name="password" placeholder="Mật khẩu">
									</div>
									<div class="form-group">
										<input type="password" class="form-control" id="repassword" name="repassword" placeholder="Nhập lại mật khẩu">
									</div>
									<div class="text-center">
										<input name="type" type="hidden" value="password"/>
										<input class="btn btn-success" type="submit" value="Đổi mật khẩu" onclick="check_password(event)"/>
									</div>
								</div>						
								<div class="col-md-5">
								</div>
							</form>
							<p class="clearfix">&nbsp;</p>
							<ul class="clearfix">
								<li>
									<a class="link" href="<?=site_url('tuyen-dung/quan-ly-tin');?>" title="Quản lý tin tuyển dụng">Quản lý tin tuyển dụng</a>
								</li>
								<li>
									<a class="link" href="<?=site_url('tuyen-dung/ho-so-da-tra-phi');?>" title="">Hồ sơ đã trả phí</a>
								</li>
								<li>
									<a class="link" href="<?=site_url('tuyen-dung/ho-so-da-nop');?>" title="">Hồ sơ đã nộp</a>
								</li>
								<!--li>
									<a class="link" href="<?=site_url('tuyen-dung/ho-so-ua-thich');?>" title="">Hồ sơ ưa thích</a>
								</li-->
							</ul>
						</div>
					</div>	
					<div id="tai_khoan" class="tab-pane fade">				
						<div class="col-md-12">
							<label class="control-label">Số điểm: <b><?=$point ? $point->so_diem : '0' ?></b></label>
							<h3>Lịch sử thanh toán</h3>
							<table class="table table-bordered">
								<thead>
									<tr>
										<td></td>
										<td>Nội dung</td>
										<td>Ngày giao dịch</td>
									</tr>
								</thead>
								<tbody>
								<?php $i = 1;
									foreach($hispay as $obj):
								?>
									<tr>
										<td><?=$i++;?></td>
										<td><?=$obj->noi_dung;?></td>
										<td><?=date('d/m/Y H:i:s', strtotime($obj->ngay));?></td>
									</tr>
								<?php endforeach;?>
								</tbody>
							</table>
						</div>
					</div>
				</div>				
			</div>
		<?php else : //rao vat?>
		<?php endif;?>
		</div>
	</div>
</div>